import type {
  AddressItem,
  Logistics,
  OrderDetail,
  OrderPre
} from '@/types/order'
import { request } from '@/utils/request'

// 获取地址
export const getAddressList = () =>
  request<AddressItem[]>('patient/order/address')

// 获取药品订单
export const getMedicalOrderPre = (prescriptionId: string) =>
  request<OrderPre>('/patient/medicine/order/pre', 'get', { prescriptionId })

// 生成 处方下药品订单 id
export const createMedicalOrder = (data: {
  id: string
  couponId?: string
  addressId: string
}) => request<{ id: string }>('patient/medicine/order', 'post', data)

// 获取药品订单支付详情
export const getMedicalOrderDetail = (id: string) =>
  request<OrderDetail>(`patient/medicine/order/detail/${id}`)

// 获取物流信息
export const getLogistics = (id: string) =>
  request<Logistics>(`patient/order/${id}/logistics`)
